<!DOCTYPE html>
<html>
<head>
  <title>Test - Culture-based String Format</title>
  <link rel="stylesheet" href="../QUnit.css" type="text/css" />
  <script type="text/javascript" src="../QUnit.js"></script>
  <script type="text/javascript" src="../QUnitExt.js"></script>
</head>
<body>
  <h1 id="qunit-header">Test Results</h1>
  <h2 id="qunit-banner"></h2>
  <h2 id="qunit-userAgent"></h2>
  <ol id="qunit-tests"></ol>
  <br />
  <textarea id="qunit-log" rows="10" cols="100"></textarea>
  <script type="text/javascript" src="../Scripts/Sharpen.debug.js"></script>
  <script type="text/javascript" src="../Scripts/Sharpen.Global.debug.js"></script>
  <script type="text/javascript">
  module('Format');
  test('formatSimple', function() {
    var s = String.format('Text: {0}', 123);
    QUnit.equal(s, 'Text: 123');
  });
  test('formatRepeated', function() {
    var s = String.format('Text: {0} -- {0:i}.', 123);
    QUnit.equal(s, 'Text: 123 -- 123.');
  });
  test('formatMultiple', function() {
    var s = String.format('Text: {0} -- {0} {1}.', 123, true);
    QUnit.equal(s, 'Text: 123 -- 123 true.');
  });
  test('formatCustom', function() {
    var s = String.format('Text: {0} -- {0} {1} {2:c} {3:id}.', 123, true, 1, new Date(2011, 0, 1));
    QUnit.equal(s, 'Text: 123 -- 123 true $1.00 Sat Jan 01 2011.');
  });
  
  test('formatSimpleCulture', function() {
    var s = String.format(ss.neutralCulture, 'Text: {0}', 123);
    QUnit.equal(s, 'Text: 123');
  });
  test('formatRepeated', function() {
    var s = String.format(ss.neutralCulture, 'Text: {0} -- {0}.', 123);
    QUnit.equal(s, 'Text: 123 -- 123.');
  });
  test('formatMultiple', function() {
    var s = String.format(ss.currentCulture, 'Text: {0} -- {0} {1}.', 123, true);
    QUnit.equal(s, 'Text: 123 -- 123 true.');
  });
  test('formatCustom', function() {
    var s = String.format(ss.neutralCulture, 'Text: {0} -- {0} {1} {2:c} {3:id}.', 123, true, 1, new Date(2011, 0, 1));
    QUnit.equal(s, 'Text: 123 -- 123 true $1.00 Sat Jan 01 2011.');
  });

  test('formatCurrency', function() {
    var s = String.format(ss.neutralCulture, 'Amount: {0:c3}', 123.5);
    QUnit.equal(s, 'Amount: $123.500');
  });

  test('formatDate', function() {
    var s = String.format(ss.neutralCulture, 'New Year in GMT: {0:r}', new Date(2011, 0, 1));
    QUnit.equal(s, 'New Year in GMT: Sat, 01 Jan 2011 00:00:00 GMT');

    var s2 = String.format(ss.neutralCulture, 'New Year in universal: {0:u}', new Date(2011, 0, 1));
    QUnit.equal(s2, 'New Year in universal: 2011-01-01 00:00:00Z');

    var s3 = String.format(ss.neutralCulture, 'New Year in UTC: {0:U}', new Date(2011, 0, 1));
    QUnit.equal(s3, 'New Year in UTC: Saturday, January 01, 2011 8:00:00 AM');

    var s4 = String.format(ss.neutralCulture, 'New Year as sortable: {0:s}', new Date(2011, 0, 1));
    QUnit.equal(s4, 'New Year as sortable: 2011-01-01T00:00:00');
  });
  </script>
</body>

</html>
